package com.todo.event.activity.application.handler.fieldtransfer;

import com.todo.event.activity.common.enums.EventFieldDataSourceEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author azhebuxing
 * @date 2025/1/9 19:42
 * @description
 */
@Component
public class FieldTransferFactory {

    @Autowired
    List<AbstractFieldTransferHandle> handleList;


    /**
     * 根据数据源类型获取对应的处理器
     *
     * @param sourceEnum
     * @return
     */
    public AbstractFieldTransferHandle getHandle(EventFieldDataSourceEnum sourceEnum) {
        for (AbstractFieldTransferHandle handle : handleList) {
            if (handle != null && sourceEnum.equals(handle.getHandleType())) {
                return handle;
            }
        }
        return null;
    }
}
